# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=himalaya
pkgver=0.5.10
pkgrel=0
pkgdesc="CLI email client"
url="https://github.com/soywod/himalaya"
license="BSD-4-Clause"
arch="all !s390x !riscv64" # blocked by rust/cargo
makedepends="cargo openssl-dev"
subpackages="$pkgname-bash-completion $pkgname-fish-completion $pkgname-zsh-completion"
source="https://github.com/soywod/himalaya/archive/v$pkgver/himalaya-$pkgver.tar.gz"

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo build --release --frozen

	./target/release/himalaya completion bash > $pkgname.bash
	./target/release/himalaya completion fish > $pkgname.fish
	./target/release/himalaya completion zsh > $pkgname.zsh
}

check() {
	# skip imap backend e2e test
	cargo test --frozen -- \
		--skip test_imap_backend
}

package() {
	install -Dm755 target/release/himalaya "$pkgdir"/usr/bin/himalaya

	install -Dm644 $pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.fish "$pkgdir"/usr/share/fish/completions/$pkgname.fish
	install -Dm644 $pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
0180ad71499109be65554a8176bffbad5c63f092b88b80bb8e82426dbc397c23f271ef4cc05fa42338a4671aca50b5ba9fd8eef7e78eef04533e7a35ee925550  himalaya-0.5.10.tar.gz
"
